<?php
/**
 * Administration Main Screen
 * This page display on the left a menu and on the right the content
 * of the page.
 * All administration point are reacheable from this page
 * 
 * @author Xavier VILAIN
 * @package Hive\Admin
 * @license #license-hive#
 */
use Fox\Authorization;
use Fox\Html\Wrapper;
use Fox\Core\Errors;
use Fox\Generator;
use Fox\Html\Navigation\Menu\Item;
use Fox\Html\Navigation\Menu\Item\Sub;
use Fox\Html\Navigation\Menu;

$xview = Xview::instance();

$defaultPage = 'process';
// Main Config
$page = Xview::instance()->val('uri','users-info');
$customizing = Hive\User\Customizing::instance();
$master = 'users';

$wrapper = new Wrapper('leftCol');
// Users
$usersMenu = new Menu('users-menu',Msg(Hive::BUNDLE,Hive::MENU_USER_SETTINGS));
// Users List
$usersMenu->add(new Item('users-info',Msg(Hive::BUNDLE,Hive::MENU_USER_PERSONAL_INFORMATION),
						Generator::url($master,'info'),null,'personal-data'));
// Add a new User
$usersMenu->add(new Item('users-authentication',Msg(Hive::BUNDLE,Hive::MENU_USER_AUTHENTICATION),
						Generator::url($master,'authentication'),null,'security'));
// Handle Contact Groups
$usersMenu->add(new Item('users-authorization',Msg(Hive::BUNDLE,Hive::MENU_USER_AUTHORIZATIONS),
						Generator::url($master,'authorization'),null,'user-group'));
// Handle Contact Groups
$usersMenu->add(new Item('users-preferences',Msg(Hive::BUNDLE,Hive::MENU_USER_PREFERENCES),
						Generator::url($master,'preferences'),null,'user-preferences'));
// Handle Contact Groups
$usersMenu->add(new Item('users-inboxes',Msg(Hive::BUNDLE,Hive::USER_MAILBOX_MENU),
						Generator::url($master,'inboxes'),null,'inbox'));
// Handle Social
$usersMenu->add(new Item('users-social',Msg(Hive::BUNDLE,Hive::MENU_USER_BE_SOCIAL),
						Generator::url($master,'social'),null,'connections'));
// Handle Kpi's
$usersMenu->add(new Item('users-kpis',Msg(Hive::BUNDLE,Hive::MENU_KPIS),
						Generator::url($master,'kpis'),null,'kpis'));						
$wrapper->add($usersMenu);

// Contact Menu
/*
$contactsMenu = new Menu('contacts',Msg(Hive::BUNDLE,Hive::MENU_CONTACTS));
$wrapper->add($contactsMenu);
*/					

if(isset($_GET['uri']) && !empty($_GET['uri']))
{
	$parts = explode('-', $_GET['uri']);
	if(count($parts) > 2) {
		$url = Generator::url($parts[0],$parts[1],$parts[2]);
	} else {
		$url = Generator::url($parts[0],$parts[1]);
	}
	
	if(!Xview::instance()->isModule($url)) {
		$url = null;
	}
}
if(empty($url))
{
	$params = array('return' => true);
	list($url,$page) = $customizing->defaultSummaryPage($params);
}
$item = $wrapper->item($page);

if(!empty($item)) {
	$wrapper->item($page)->selected();
}
$edit = '<div id="leftColContainer">
			<div id="leftCol">
			<div id="pagelet_welcome_box">
				<div class="hive-missions-box">
				</div>
			</div>
			<div id="pagelet_navigation">
				<div class="uiFutureSideNav">
				'.$wrapper->render().'
			</div>
		</div>
		</div>';
?>
<div id="leftColContainer" >
	<div id="leftCol">
		<div id="pagelet_welcome_box">
			<div class="hive-contact-box">
				<div class="clearfix uiImageBlock">
					<div class="ui-image-block-content" >
						<img src="<?php echo User::current()->profilePictureUrl(true) ?>" />
						<span class="title"><?php echo User::current()->name(); ?></span>
						<div class="i"></div>
					</div>
				</div>			
			</div>
		</div>
		<div id="pagelet_navigation">
			<div class="uiFutureSideNav">
			<?php echo $wrapper->render(); ?>
			</div>
		</div>
	</div>
</div>
<div id="contentCol" class="hasLeftCol" style="padding-left: 5px; padding-top: 5px; ">
	<?php echo Xview::instance()->display($url); ?>
</div>